#include "stdafx.h"

namespace classifier_test
{

classifier_common::classifier_common()
{
	Options = 0;
}

classifier_common::classifier_common(const classifier_common& Val)
{
	Domain = Val.Domain;
	ClassCount = Val.ClassCount;
	Options = Val.Options;
}

void classifier_common::serialize(serializer& Serializer)
{
	Serializer("Domain", Domain);
	ClassCount = Domain.back().discr.count;
}

const record_domain& classifier_common::get_domain() const
{
	return Domain;
}

void classifier_common::set_domain(const record_domain& Val)
{
	assert(Val.back().type == discr_attr);
	Domain = Val;
	ClassCount = Domain.back().discr.count;
}

const command_line_options& classifier_common::get_options() const
{
	if (Options != 0) return *Options;
	static map<const type_info*, command_line_options> P;
	Options = &P[&typeid(*this)];
	initialize_options(*Options);
	return *Options;
}

void classifier_common::apply_arguments(subarray<const command_line_argument> Args)
{
	apply_arguments(command_line_arguments(get_options(), Args));
}

void classifier_common::initialize_options(command_line_options& Options) const
{
	Options.add("help").set_info("Display this information");
}

void classifier_common::apply_arguments(const command_line_arguments& Args)
{
	if (!Args["help"].empty()) Options->show_help();
}

}
